package com.sn.system.common.validator.validators;

import java.util.List;
import java.util.Map;

import com.opensymphony.xwork2.validator.ValidationException;
import com.opensymphony.xwork2.validator.validators.FieldValidatorSupport;

public class ShortCircuitRequiredValidator extends FieldValidatorSupport{
	public void validate(Object object) throws ValidationException {
		 String fieldName = getFieldName();
	        Object val1 = this.getFieldValue(fieldName, object);
	        
	        String fullName= getValidatorContext().getFullFieldName(fieldName);
	        Map<String,List<String>> fieidErrors=getValidatorContext().getFieldErrors();
	        if(fieidErrors.containsKey(fullName)){
	        	return;
	        }
	        if (val1 == null ) {
	        	addFieldError(fieldName, object);
		        return;
	        }
	}
}
